package com.longge.wechat.controller.wx;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.longge.wechat.message.post.Image;
import com.longge.wechat.message.post.PostImageMessage;
import com.longge.wechat.message.wxUtil.WeiXinUtil;



@Controller
public class PostImageController {

	
	@RequestMapping(value = "/respImage.do", method = RequestMethod.POST)
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String content = "";
		String openId = (String) request.getAttribute("openId");
		PostImageMessage pim = new PostImageMessage();
		pim.setTouser(openId);
		pim.setMsgtype("image");
		Image image = new Image();
		
		image.setMedia_id("7686796797");
		pim.setImage(image);
		int result = WeiXinUtil.sendInfo(pim);
		if(result == 1) {
			content = "发送图片消息成功";
		}
		System.out.println(content);
	}
}
